package best.driver.android;

import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import best.driver.android.AppConfig;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import best.driver.android.common.app.AppProxy;
import best.driver.android.common.app.AppProxyFactory;
import best.driver.android.common.app.IAppConfig;
import best.driver.android.common.network.ApiRequest;
import best.driver.android.common.network.BestError;

import java.lang.ref.WeakReference;
import java.util.LinkedList;
import java.util.List;


public class CustomerAppProxy extends AppProxy {

    private AppConfig mAppConfig = new AppConfig();

    private DisplayImageOptions mDriverHeadDisplayOptions;

    private static Handler sHandler = new Handler();

    private static List<WeakReference<Activity>> sGlobalActivityStack = new LinkedList<WeakReference<Activity>>();




    public static CustomerAppProxy getProxy() {
        return (CustomerAppProxy) AppProxyFactory.getProxy();
    }

    public Handler getsHandler() {
        return sHandler;
    }
    @Override
    public void init(Context ctx) {
        super.init(ctx);
        ApiRequest.registerErrorFilter(ApiRequestErrorFilterImpl.class);
    }

    @Override
    public IAppConfig getAppConfig() {
        return mAppConfig;
    }

    public static class ApiRequestErrorFilterImpl implements ApiRequest.ApiRequestErrorFilter {

        private boolean mAlertLogout = false;

        @Override
        public boolean shouldFilterError(BestError error) {

            return false;
        }

    }

    public DisplayImageOptions getDriverHeadDisplayOptions() {
        if (mDriverHeadDisplayOptions == null) {
            mDriverHeadDisplayOptions = new DisplayImageOptions.Builder()
                    .cacheInMemory(true)
                    .cacheOnDisk(true)
                    .build();
        }
        return mDriverHeadDisplayOptions;
    }


}
